package cn.tony.game.super_tank;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.UnknownHostException;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class SettingFame extends JFrame {

    public GameClient cl;

    public SettingFame(GameClient cl) {
        this.cl = cl;
        setLocation(300, 300);
        setLayout(new FlowLayout());
        setResizable(true);

        JLabel ipl = new JLabel("服务器ip");
        add(ipl);
        JTextField iptext = new JTextField("10.8.152.210", 25);

        add(iptext);
        JLabel namel = new JLabel("玩家名称");
        add(namel);
        JTextField nametext = new JTextField("玩家名称", 30);
        add(nametext);
        JButton start = new JButton("JOIN");
        add(start);
        start.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println("");
                cl.ip = iptext.getText();
                cl.name = nametext.getText();
                show1(false);
                try {
                    cl.conn();
                } catch (UnknownHostException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (IOException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
                
            }
        });
        pack();

    }

    public void show1(boolean flag) {

        setVisible(flag);
    }


}
